package org.jeecg.modules.bigdatashow.service.impl;

import org.jeecg.modules.bigdatashow.entity.*;
import org.jeecg.modules.bigdatashow.mapper.GeneralMapper;
import org.jeecg.modules.bigdatashow.service.GeneralService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GeneralServiceImpl implements GeneralService {
    @Autowired
    private GeneralMapper generalMapper;



    @Override
    public List<General> showList() {
       
        //获取游客数量进行更新
        Integer total = generalMapper.findAll();
        generalMapper.updateTotal(total);
        //获取男女性别数量对总表进行更新
        Integer man =generalMapper.getManSex();
        Integer woman = generalMapper.getWomanSex();
        System.out.println(man);
        System.out.println(woman);
        //对总表中的值进行更新
        generalMapper.updateSex(man,woman);
        //获取团队/散客游客数量
        Integer ttourist = generalMapper.getttourist();
        Integer stourist = generalMapper.getstourist();
        //对总表进行更新
        generalMapper.updateTourist(ttourist,stourist);
        return generalMapper.showList();

    }

    @Override
    public Sex showSex() {
        return generalMapper.showSex();
    }

    @Override
    public Ages showAge() {
        Ages ages = new Ages();
        //获取各个年龄段的数量
        Integer shaonian = generalMapper.getShaoNian();
        Integer qingnian = generalMapper.getQingNian();
        Integer zhongnian = generalMapper.getZhongNian();
        Integer laonian = generalMapper.getLaoNian();
        Integer qita = generalMapper.getQiTa();
        ages.setShaonian(shaonian);
        ages.setQingnian(qingnian);
        ages.setZhongnian(zhongnian);
        ages.setLaoNian(laonian);
        ages.setQita(qita);
        System.out.println(ages);
        return ages;
    }

    @Override
    public From showFrom() {
        From from = new From();
        Integer ShengNei = generalMapper.getShengNei();
        Integer BeiFang = generalMapper.getBeiFang();
        Integer NanFang = generalMapper.getNanFang();
        Integer HaiWai = generalMapper.getHaiWai();
        Integer Other = generalMapper.getOther();
        from.setShengnei(ShengNei);
        from.setBeiFang(BeiFang);
        from.setNanFang(NanFang);
        from.setHaiWai(HaiWai);
        from.setOther(Other);

        return from;
    }

}
